class ChambresController < ApplicationController
  
  layout 'chambres'
  before_filter :find_chambre, :only => [:show, :edit, :update, :destroy]
  # GET /chambres
  # GET /chambres.xml
  def index
    @chambres = Chambre.search(params[:search]).paginate(:page => params[:page], :per_page => 10)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @chambres }
    end
  end

  # GET /chambres/1
  # GET /chambres/1.xml
  def show
    

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @chambre }
    end
  end

  # GET /chambres/new
  # GET /chambres/new.xml
  def new
    @chambre = Chambre.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @chambre }
    end
  end

  # GET /chambres/1/edit
  def edit
    
  end

  # POST /chambres
  # POST /chambres.xml
  def create
    @chambre = Chambre.new(params[:chambre])

    respond_to do |format|
      if @chambre.save
        flash[:notice] = 'Chambre was successfully created.'
        format.html { redirect_to(@chambre) }
        format.xml  { render :xml => @chambre, :status => :created, :location => @chambre }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @chambre.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /chambres/1
  # PUT /chambres/1.xml
  def update
  

    respond_to do |format|
      if @chambre.update_attributes(params[:chambre])
        flash[:notice] = 'Chambre was successfully updated.'
        format.html { redirect_to(@chambre) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @chambre.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /chambres/1
  # DELETE /chambres/1.xml
  def destroy
    @chambre.destroy

    respond_to do |format|
      format.html { redirect_to(chambres_url) }
      format.xml  { head :ok }
    end
  end
  
  private
    def find_chambre
      @chambre = Chambre.find(params[:id])
    end
end
